﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI;

namespace KioskosJugandoLimpio.Classes
{
    
    public class DIVformat
    {
        private HtmlGenericControl divTemp;

        public DIVformat(string strId)
        {
            divTemp = new HtmlGenericControl("div");
            divTemp.ID = strId;
            divTemp.ClientIDMode = ClientIDMode.Static;
        }

        public void addLabel(string strText, string strClassCss)
        {
            HtmlGenericControl spanTemp = new HtmlGenericControl("span");            
            spanTemp.InnerText = strText;
            spanTemp.Attributes.Add("class",strClassCss);
            divTemp.Controls.Add(spanTemp);
        }

        public void addLink(string strText, string strOnclick)
        {
            HtmlGenericControl alinkTemp = new HtmlGenericControl("a");
            alinkTemp.InnerText = strText;
            alinkTemp.Attributes.Add("onclick", strOnclick);
            divTemp.Controls.Add(alinkTemp);            
        }

        public void addTextBox(string strText, string strName, string strId, string strClassCss, string strStyle)
        {
            HtmlGenericControl tbxTemp = new HtmlGenericControl("input");
            tbxTemp.Attributes.Add("name", strName);
            tbxTemp.Attributes.Add("id", strId);
            tbxTemp.Attributes.Add("type","text");
            tbxTemp.Attributes.Add("value", strText);
            tbxTemp.Attributes.Add("class", strClassCss);
            tbxTemp.Attributes.Add("style", strStyle);
            tbxTemp.ClientIDMode = ClientIDMode.Static;
            divTemp.Controls.Add(tbxTemp);            
        }

        public void addTextArea(string strText, string strName, string strID, string strClassCss, string strStyle)
        {
            if (strText == null)
            {
                strText = "";
            }
            HtmlGenericControl tbxTemp = new HtmlGenericControl("textarea");
            tbxTemp.InnerText = strText.ToString();
            tbxTemp.Attributes.Add("name", strName);
            tbxTemp.Attributes.Add("id", strID);
            tbxTemp.Attributes.Add("class", strClassCss);
            tbxTemp.Attributes.Add("style", strStyle);
            tbxTemp.Attributes.Add("rows", "4");
            tbxTemp.Attributes.Add("cols", "20");
            tbxTemp.ClientIDMode = ClientIDMode.Static;
            divTemp.Controls.Add(tbxTemp);
            addNewLine(); 
        }

        public void addRadio(string strText, string strName, string strClassCss, bool Marcado)
        {
            HtmlGenericControl radioTemp = new HtmlGenericControl("input");
            radioTemp.InnerText = strText;
            radioTemp.Attributes.Add("type", "radio");
            radioTemp.Attributes.Add("name", strName);
            radioTemp.Attributes.Add("class", strClassCss);
            if (Marcado)
                radioTemp.Attributes.Add("checked", "checked");
            divTemp.Controls.Add(radioTemp);
        }

        public void addNewLine()
        {
            divTemp.Controls.Add(new HtmlGenericControl("br"));
        }

        public Control getDIV()
        {
            return divTemp;
        }        

        public void addControl(Control control)
        {
            divTemp.Controls.Add(control);
        }

        internal void addCheckBox(string strName, bool blnVisble)
        {
            HtmlGenericControl checkboxTemp = new HtmlGenericControl("input");
            checkboxTemp.Attributes.Add("name", strName);  
            checkboxTemp.Attributes.Add("type", "checkbox");
            if (blnVisble)
                checkboxTemp.Attributes.Add("checked", "checked");  
            divTemp.Controls.Add(checkboxTemp);
        }
    }
}